<%@ page import="com.lagou.bena.Student" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2020/9/14 0014
  Time: 17:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>管理员操作页面</title>
    <link rel="stylesheet" href="./css/bootstrap.min.css">
    <script src="./js/jquery-3.3.1.min.js"></script>
    <script src="./js/bootstrap.min.js"></script>
</head>
<style>
    h2{
        text-align: center;
        font-family: "华文琥珀", serif;
        color: gray;
    }
</style>

<body>
<div class="container">
    <h2>学生信息列表</h2>
    <div style="float: left; padding: 10px;">
        <form class="form-inline" id="query" action="queryStu" method="post">
            <div class="form-group">
                <label for="info">备注</label>
                <input type="text" name="info" class="form-control" id="info">
            </div>
            <div class="form-group">
                <label for="stuName">姓名</label>
                <input type="text" name="stuName" class="form-control" id="stuName">
            </div>

            <div class="form-group">
                <label for="email">邮箱</label>
                <input type="text" name="email" class="form-control" id="email">
            </div>
            <a class="btn btn-primary" href="addStu.jsp">添加学生</a>
            &nbsp;<a class="btn btn-danger" data-toggle="modal" data-target="#mymodal">删除学生</a>
            &nbsp;<a class="btn btn-warning" href="update.jsp">修改学生</a>
            &nbsp;<button type="submit" class="btn btn-info">查询学生</button>
        </form>
    </div>

    <table border="1px" class="table table-bordered table-hover">
        <tr class="success">
            <th>学号</th>
            <th>姓名</th>
            <th>性别</th>
            <th>出生日期</th>
            <th>邮箱</th>
            <th>备注</th>
        </tr>
        <%
            List<Student> students = (List<Student>) session.getAttribute("students");
            for (Student student : students) {
        %>
        <tr>
            <td><%=student.getStuID()%></td>
            <td><%=student.getStuName()%></td>
            <td><%=student.getSex()%></td>
            <td><%=student.getBirthday()%></td>
            <td><%=student.getEmail()%></td>
            <td><%=student.getInfo()%></td>
        </tr>
        <%
            }
            // 嵌入java代码，添加学生信息成功的弹框提示
            String addRes = (String) session.getAttribute("addRes");
            if ("success".equals(addRes)) {
        %>
        <script>
            alert("添加学生信息成功！")
        </script>
        <%
                session.setAttribute("addRes", "");// 只有执行添加操作并且添加成功才会弹框
            }
            // 嵌入java代码，修改学生信息成功的弹框提示
            String updateRes = (String) session.getAttribute("updateRes");
            if ("success".equals(updateRes)) {
        %>
        <script>
            alert("修改学生信息成功！")
        </script>
        <%
                session.setAttribute("updateRes", ""); // 只有执行修改操作并且修改成功时才会弹框
            }
            // 嵌入java代码，删除学生信息成功的弹框提示
            String delRes = (String) session.getAttribute("delRes");
            if ("success".equals(delRes)) {
        %>
        <script>
            alert("删除学生信息成功！")
        </script>
        <%
                session.setAttribute("delRes", ""); // 只有执行删除操作并且修改成功时才会弹框
            }
        %>
    </table>
    <ul class="pager">
        <li class="previous"><a href="#">&laquo;</a></li>
        <li class="active"><a href="#">1</a></li>
        <li><a href="#">2</a></li>
        <li><a href="#">3</a></li>
        <li class="next"><a href="#">&raquo;</a></li>
    </ul>
<%--    <ul class="pagination">--%>
<%--        <li class="previous"><a href="#">&laquo;</a></li>--%>
<%--        <li class="active"><a href="#">1</a></li>--%>
<%--        <li><a href="#">2</a></li>--%>
<%--        <li><a href="#">3</a></li>--%>
<%--        <li class="next"><a href="#">&raquo;</a></li>--%>
<%--    </ul>--%>
</div>

<!-- 声明定义模态框组件 -->
<form action="deleteStu" method="post">
    <div class="modal" id="mymodal" data-backdrop="static">
        <!-- 声明弹框 -->
        <div class="modal-dialog">
            <!-- 弹框内容 -->
            <div class="modal-content">
                <!-- 框的标题 -->
                <div class="modal-header">
                    <button class="close" data-dismiss="modal">
                        <span>&times;</span>
                    </button>
                    <h4 class="modal-title">删除学生信息</h4>
                </div>
                <!-- 框的内容 -->
                <div class="modal-body">
                    <label>学号</label>
                    <input type="text" class="form-control" name="stuID" placeholder="请输入要删除学生的学号">
                </div>
                <!-- 框的按钮 -->
                <div class="modal-footer">
                    <button class="btn btn-info" type="submit">确定</button>
                    <button class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>
</form>
</body>
</html>
